const { query } = require("../db/query")
module.exports = {
  // 查询用户
  findUser: async (user_mobile) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query(`select * from user where user_mobile = ${user_mobile}`)
  },
  // 注册用户
  registerUser: async (user_name, user_password, user_mobile, user_gender) => {
    const user_id = user_mobile;
    // 调用query发送sql语句到mysql进行注册用户
    return await query("insert into user(user_id,user_name,user_password,user_mobile,user_gender) VALUES(?,?,?,?,?)", [user_id, user_name, user_password, user_mobile, user_gender])
  },
  editInformation: async (user_id, user_name, user_gender, user_age, user_address, user_intro, user_avatar) => {
    // 调用query发送sql语句到mysql进行注册用户
    return await query(`update user set user_name =?, user_gender =?, user_age =?, user_address =?, user_intro =?, user_avatar =? where user_id =?`, [user_name, user_gender, user_age, user_address, user_intro, user_avatar, user_id])
  },
}